package com.bw.zonghe0719.utils

import android.os.Bundle
import android.webkit.WebChromeClient
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import androidx.core.view.isVisible
import com.alibaba.android.arouter.facade.annotation.Autowired
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.bw.base.mvvm.BaseViewActivity
import com.bw.zonghe0719.R
import com.bw.zonghe0719.databinding.ActivityWebViewBinding

/**
 * 封装WebView 界面  多个请求都可以在这个代码中展示
 */
@Route(path = "/app/utils/WebViewActivity")
class WebViewActivity : BaseViewActivity<ActivityWebViewBinding>(){
    @JvmField
    @Autowired
    var url=""//不公开     @JvmField变成JAVA中的public   公开
//    @Autowired(name = "")    当跳转页面传入参数名称和接收方接收的参数名称不一致时  可用“name”重新命名    一致时 "name"可省略
//    lateinit var url:String
    override fun initView() {
        ARouter.getInstance().inject(this)
        binding.wv.loadUrl(url)
        binding.wv.webViewClient= WebViewClient()//在web页面内部显示加载内容
        var webChromeClient=object :WebChromeClient(){
            override fun onProgressChanged(view: WebView?, newProgress: Int) {
                super.onProgressChanged(view, newProgress)
                if(newProgress==100){
                    binding.pb.isVisible=false
                }
                binding.pb.progress=newProgress
            }
        }
        binding.wv.webChromeClient=webChromeClient//显示进度条
        binding.wv.settings.javaScriptEnabled=true//设置web页面可点击
    }

    override fun initData() {

    }

    override fun getLayoutId(): Int {
      return R.layout.activity_web_view
    }
}